<template>
  <div>
    <div style="position: fixed; top: 0; z-index: 9999;">
      <user-tab :selected="currentTab" @selectTab="onTabSelected"></user-tab>
    </div>

    <div style="height: 50px"></div>
    <transition>
      <keep-alive>
        <router-view/>
      </keep-alive>
    </transition>
  </div>

</template>

<script>
  import UserTab from './components/UserTab'

  export default {
    name: "user-index",
    data() {
      return {
        currentTab: 0
      }
    },
    components: {
      UserTab
    },
    watch: {
      routePath(val) {
        this.changeCurrentTab()
      },
    },
    created() {
      this.changeCurrentTab()
    },
    methods: {
      onTabSelected(data) {
        this.currentTab = data.tab
      },
      changeCurrentTab() {
        if (this.$route.path.includes('/cert/')) {
          this.currentTab = 1
        } else if (this.$route.path.includes('/history/')) {
          this.currentTab = 0
        }
      }
    }
  }
</script>

<style scoped>

</style>
